+2007-12-14 Mathias Hasselmann <mathias@openismus.com>
+
+ Change GtkToolItem to retrieve its properties from GtkToolShell
+ interface, instead of relying on being child of a GtkToolbar.
+ (#5034079)
+
+ * gtk/gtk.symbols, docs/reference/gtk/gtk-docs.sgml,
+ docs/reference/gtk/gtk-sections.txt: Add GtkToolShell symbols.
+ * docs/reference/gtk/tmpl/gtktoolitem.sgml: Move section docs inline.
+ * gtk/gtktoolbar.c: Implement GtkToolShellIface.
+ * gtk/gtktoolbar.h: Remove _gtk_toolbar_rebuild_menu.
+ * gtk/gtktoolitem.c: Use GtkToolShell, instead of GtkToolbar.
+ Take section docs from template file and update them for GtkToolShell.
+ * gtk/Makefile.am: Add gtk/gtktoolshell.c and gtk/gtktoolshell.h.
+ * gtk/gtktoolshell.c, gtk/gtktoolshell.h: New GtkToolShellIface.
+
2007-12-14 Mathias Hasselmann <mathias@openismus.com>
Extract loading of GtkPageSetup and GtkPrintSettings from their
<!ENTITY GtkToggleAction SYSTEM "xml/gtktoggleaction.xml">
<!ENTITY GtkToggleButton SYSTEM "xml/gtktogglebutton.xml">
<!ENTITY GtkToggleToolButton SYSTEM "xml/gtktoggletoolbutton.xml">
+<!ENTITY GtkToolShell SYSTEM "xml/gtktoolshell.xml">
<!ENTITY GtkToolbar SYSTEM "xml/gtktoolbar.xml">
<!ENTITY GtkToolButton SYSTEM "xml/gtktoolbutton.xml">
<!ENTITY GtkToolItem SYSTEM "xml/gtktoolitem.xml">
<releaseinfo>for GTK+ &version;</releaseinfo>
</bookinfo>
+<!--
<part id="gtk">
<title>GTK+ Overview</title>
<partintro>
&GtkListStore;
&GtkTreeStore;
</chapter>
-
+-->
<chapter id="MenusAndCombos">
<title>Menus, Combo Box, Toolbar</title>
&GtkComboBox;
&GtkCheckMenuItem;
&GtkSeparatorMenuItem;
&GtkTearoffMenuItem;
+ &GtkToolShell;
&GtkToolbar;
&GtkToolItem;
&GtkSeparatorToolItem;
&GtkToggleToolButton;
&GtkRadioToolButton;
</chapter>
-
+<!--
<chapter id="Actions">
<title>Action-based menus and toolbars</title>
&GtkUIManager;
<index role="2.12">
<title>Index of new symbols in 2.12</title>
</index>
-
+-->
</book>
gtk_toggle_button_get_type
</SECTION>
+<SECTION>
+<FILE>gtktoolshell</FILE>
+<TITLE>GtkToolShell</TITLE>
+GtkToolShell
+GtkToolShellIface
+gtk_tool_shell_get_icon_size
+gtk_tool_shell_get_orientation
+gtk_tool_shell_get_relief_style
+gtk_tool_shell_get_style
+gtk_tool_shell_rebuild_menu
+
+<SUBSECTION Private>
+gtk_tool_shell_get_type
+</SECTION>
+
<SECTION>
<FILE>gtktoolbar</FILE>
<TITLE>GtkToolbar</TITLE>
GtkPageSetupUnixDialogPrivate
gtk_page_setup_unix_dialog_get_type
</SECTION>
+
GtkToolItem
<!-- ##### SECTION Short_Description ##### -->
-The base class of widgets that can be added to GtkToolbar
<!-- ##### SECTION Long_Description ##### -->
<para>
-#GtkToolItem<!-- -->s are widgets that can appear on a toolbar. To
-create a toolbar item that contain something else than a button, use
-gtk_tool_item_new(). Use gtk_container_add() to add a child
-widget to the tool item.
-</para>
-<para>
-For toolbar items that contain buttons, see the #GtkToolButton,
-#GtkToggleToolButton and #GtkRadioToolButton classes.
-</para>
-See the #GtkToolbar class for a description of the toolbar widget.
-<para>
+
</para>
<!-- ##### SECTION See_Also ##### -->
<!-- ##### STRUCT GtkToolItem ##### -->
<para>
-The GtkToolItem struct contains only private data. It should only be
-accessed through the functions described below.
+
</para>
gtktoolbar.h \
gtktoolbutton.h \
gtktoolitem.h \
+ gtktoolshell.h \
gtktooltip.h \
gtktooltips.h \
gtktree.h \
gtktoolbar.c \
gtktoolbutton.c \
gtktoolitem.c \
+ gtktoolshell.c \
gtktooltip.c \
gtktooltips.c \
gtktree.c \
#endif
#endif
+#if IN_HEADER(__GTK_TOOL_SHELL_H__)
+#if IN_FILE(__GTK_TOOL_SHELL_C__)
+gtk_tool_shell_get_icon_size
+gtk_tool_shell_get_orientation
+gtk_tool_shell_get_style
+gtk_tool_shell_get_relief_style
+gtk_tool_shell_rebuild_menu
+#endif
+#endif
+
#if IN_HEADER(__GTK_TOOL_BUTTON_H__)
#if IN_FILE(__GTK_TOOL_BUTTON_C__)
gtk_tool_button_get_icon_name
#include <config.h>
#include "gtkarrow.h"
#include "gtktoolbar.h"
+#include "gtktoolshell.h"
#include "gtkradiotoolbutton.h"
#include "gtkseparatortoolitem.h"
#include "gtkmenu.h"
static void toolbar_content_set_expand (ToolbarContent *content,
gboolean expand);
+static void toolbar_tool_shell_iface_init (GtkToolShellIface *iface);
+static GtkIconSize toolbar_get_icon_size (GtkToolShell *shell);
+static GtkOrientation toolbar_get_orientation (GtkToolShell *shell);
+static GtkToolbarStyle toolbar_get_style (GtkToolShell *shell);
+static GtkReliefStyle toolbar_get_relief_style (GtkToolShell *shell);
+static void toolbar_rebuild_menu (GtkToolShell *shell);
+
#define GTK_TOOLBAR_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_TOOLBAR, GtkToolbarPrivate))
static guint toolbar_signals [LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (GtkToolbar, gtk_toolbar, GTK_TYPE_CONTAINER)
+G_DEFINE_TYPE_WITH_CODE (GtkToolbar, gtk_toolbar, GTK_TYPE_CONTAINER,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_TOOL_SHELL, toolbar_tool_shell_iface_init))
static void
add_arrow_bindings (GtkBindingSet *binding_set,
GTK_TYPE_DIRECTION_TYPE, direction);
}
+static void
+toolbar_tool_shell_iface_init (GtkToolShellIface *iface)
+{
+ iface->get_icon_size = toolbar_get_icon_size;
+ iface->get_orientation = toolbar_get_orientation;
+ iface->get_style = toolbar_get_style;
+ iface->get_relief_style = toolbar_get_relief_style;
+ iface->rebuild_menu = toolbar_rebuild_menu;
+}
+
static void
gtk_toolbar_class_init (GtkToolbarClass *klass)
{
}
if (GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unrealize) (widget);
+ GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unrealize (widget);
}
static gint
GtkWidget *child = toolbar_content_get_widget (content);
if (child)
- (*callback) (child, callback_data);
+ callback (child, callback_data);
}
list = next;
}
if (include_internals)
- (* callback) (priv->arrow_button, callback_data);
+ callback (priv->arrow_button, callback_data);
}
static GType
return result;
}
-void
-_gtk_toolbar_rebuild_menu (GtkToolbar *toolbar)
+static GtkIconSize
+toolbar_get_icon_size (GtkToolShell *shell)
{
- GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
+ return GTK_TOOLBAR (shell)->icon_size;
+}
+
+static GtkOrientation
+toolbar_get_orientation (GtkToolShell *shell)
+{
+ return GTK_TOOLBAR (shell)->orientation;
+}
+
+static GtkToolbarStyle
+toolbar_get_style (GtkToolShell *shell)
+{
+ return GTK_TOOLBAR (shell)->style;
+}
+
+static GtkReliefStyle
+toolbar_get_relief_style (GtkToolShell *shell)
+{
+ return get_button_relief (GTK_TOOLBAR (shell));
+}
+
+static void
+toolbar_rebuild_menu (GtkToolShell *shell)
+{
+ GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (shell);
GList *list;
priv->need_rebuild = TRUE;
toolbar_content_set_unknown_menu_status (content);
}
- gtk_widget_queue_resize (GTK_WIDGET (toolbar));
+ gtk_widget_queue_resize (GTK_WIDGET (shell));
}
#define __GTK_TOOLBAR_C__
GdkRectangle *area,
GtkAllocation *allocation);
gint _gtk_toolbar_get_default_space_size (void);
-void _gtk_toolbar_rebuild_menu (GtkToolbar *toolbar);
void gtk_toolbar_set_icon_size (GtkToolbar *toolbar,
#include <config.h>
#include "gtktoolitem.h"
#include "gtkmarshalers.h"
-#include "gtktoolbar.h"
+#include "gtktoolshell.h"
#include "gtkseparatormenuitem.h"
#include "gtkintl.h"
#include "gtkmain.h"
#include <string.h>
+/**
+ * SECTION:gtktoolitem
+ * @short_description: The base class of widgets that can be added to #GtkToolShell
+ *
+ * #GtkToolItem<!-- -->s are widgets that can appear on a toolbar. To
+ * create a toolbar item that contain something else than a button, use
+ * gtk_tool_item_new(). Use gtk_container_add() to add a child
+ * widget to the tool item.
+ *
+ * For toolbar items that contain buttons, see the #GtkToolButton,
+ * #GtkToggleToolButton and #GtkRadioToolButton classes.
+ *
+ * See the #GtkToolbar class for a description of the toolbar widget, and
+ * #GtkToolShell for a description of the tool shell interface.
+ */
+
+/**
+ * GtkToolItem:
+ *
+ * The GtkToolItem struct contains only private data.
+ * It should only be accessed through the functions described below.
+ */
+
enum {
CREATE_MENU_PROXY,
TOOLBAR_RECONFIGURED,
* item is a child of changes. For custom subclasses of #GtkToolItem,
* the default handler of this signal use the functions
* <itemizedlist>
- * <listitem>gtk_toolbar_get_orientation()</listitem>
- * <listitem>gtk_toolbar_get_style()</listitem>
- * <listitem>gtk_toolbar_get_icon_size()</listitem>
- * <listitem>gtk_toolbar_get_relief_style()</listitem>
+ * <listitem>gtk_tool_shell_get_orientation()</listitem>
+ * <listitem>gtk_tool_shell_get_style()</listitem>
+ * <listitem>gtk_tool_shell_get_icon_size()</listitem>
+ * <listitem>gtk_tool_shell_get_relief_style()</listitem>
* </itemizedlist>
* to find out what the toolbar should look like and change
* themselves accordingly.
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ICON_SIZE_LARGE_TOOLBAR);
parent = GTK_WIDGET (tool_item)->parent;
- if (!parent || !GTK_IS_TOOLBAR (parent))
+ if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_ICON_SIZE_LARGE_TOOLBAR;
- return gtk_toolbar_get_icon_size (GTK_TOOLBAR (parent));
+ return gtk_tool_shell_get_icon_size (GTK_TOOL_SHELL (parent));
}
/**
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
parent = GTK_WIDGET (tool_item)->parent;
- if (!parent || !GTK_IS_TOOLBAR (parent))
+ if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_ORIENTATION_HORIZONTAL;
- return gtk_toolbar_get_orientation (GTK_TOOLBAR (parent));
+ return gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (parent));
}
/**
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_TOOLBAR_ICONS);
parent = GTK_WIDGET (tool_item)->parent;
- if (!parent || !GTK_IS_TOOLBAR (parent))
+ if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_TOOLBAR_ICONS;
- return gtk_toolbar_get_style (GTK_TOOLBAR (parent));
+ return gtk_tool_shell_get_style (GTK_TOOL_SHELL (parent));
}
/**
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_RELIEF_NONE);
parent = GTK_WIDGET (tool_item)->parent;
- if (!parent || !GTK_IS_TOOLBAR (parent))
+ if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_RELIEF_NONE;
- return gtk_toolbar_get_relief_style (GTK_TOOLBAR (parent));
+ return gtk_tool_shell_get_relief_style (GTK_TOOL_SHELL (parent));
}
/**
widget = GTK_WIDGET (tool_item);
- if (widget->parent && GTK_IS_TOOLBAR (widget->parent))
- _gtk_toolbar_rebuild_menu (GTK_TOOLBAR (widget->parent));
+ if (widget->parent && GTK_IS_TOOL_SHELL (widget->parent))
+ gtk_tool_shell_rebuild_menu (GTK_TOOL_SHELL (widget->parent));
}
/**
--- /dev/null
+/* gtktoolshell.c
+ * Copyright (C) 2007 Openismus GmbH
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:
+ * Mathias Hasselmann
+ */
+
+#include <config.h>
+#include "gtktoolshell.h"
+#include "gtkwidget.h"
+#include "gtkintl.h"
+#include "gtkalias.h"
+
+/**
+ * SECTION:gtktoolshell
+ * @short_description: Interface for containers containing #GtkToolItem widgets.
+ *
+ * The #GtkToolShell interface allows container widgets to provide additional
+ * information when embedding #GtkToolItem widgets.
+ *
+ * @see_also: #GtkToolbar, #GtkToolItem
+ */
+
+/**
+ * GtkToolShell:
+ *
+ * Dummy structure for accessing instances of #GtkToolShellIface.
+ */
+
+GType
+gtk_tool_shell_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type)
+ {
+ type = g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkToolShell"),
+ sizeof (GtkToolShellIface),
+ NULL, 0, NULL, 0);
+ g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET);
+ }
+
+ return type;
+}
+
+/**
+ * gtk_tool_shell_get_icon_size:
+ * @shell: a #GtkToolShell
+ *
+ * Retrieves the icon size for the tool shell. Tool items must not call this
+ * function directly, but rely on gtk_tool_item_get_icon_size() instead.
+ *
+ * Return value: the current size for icons of @shell
+ *
+ * Since: 2.16
+ **/
+GtkIconSize
+gtk_tool_shell_get_icon_size (GtkToolShell *shell)
+{
+ return GTK_TOOL_SHELL_GET_IFACE (shell)->get_icon_size (shell);
+}
+
+/**
+ * gtk_tool_shell_get_orientation:
+ * @shell: a #GtkToolShell
+ *
+ * Retrieves the current orientation for the tool shell. Tool items must not
+ * call this function directly, but rely on gtk_tool_item_get_orientation()
+ * instead.
+ *
+ * Return value: the current orientation of @shell
+ *
+ * Since: 2.16
+ **/
+GtkOrientation
+gtk_tool_shell_get_orientation (GtkToolShell *shell)
+{
+ return GTK_TOOL_SHELL_GET_IFACE (shell)->get_orientation (shell);
+}
+
+/**
+ * gtk_tool_shell_get_style:
+ * @shell: a #GtkToolShell
+ *
+ * Retrieves whether the tool shell has text, icons, or both. Tool items must
+ * not call this function directly, but rely on gtk_tool_item_get_style()
+ * instead.
+ *
+ * Return value: the current style of @shell
+ *
+ * Since: 2.16
+ **/
+GtkToolbarStyle
+gtk_tool_shell_get_style (GtkToolShell *shell)
+{
+ return GTK_TOOL_SHELL_GET_IFACE (shell)->get_style (shell);
+}
+
+/**
+ * gtk_tool_shell_get_relief_style:
+ * @shell: a #GtkToolShell
+ *
+ * Returns the relief style of buttons on @shell. Tool items must not call this
+ * function directly, but rely on gtk_tool_item_get_relief_style() instead.
+ *
+ * Return value: The relief style of buttons on @shell.
+ *
+ * Since: 2.16
+ **/
+GtkReliefStyle
+gtk_tool_shell_get_relief_style (GtkToolShell *shell)
+{
+ GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
+
+ if (iface->get_relief_style)
+ iface->get_relief_style (shell);
+
+ return GTK_RELIEF_NONE;
+}
+
+/**
+ * gtk_tool_shell_rebuild_menu:
+ * @shell: a #GtkToolShell
+ *
+ * Calling this function signals the tool shell that the overflow menu item for
+ * tool items have changed. If there is an overflow menu and if it is visible
+ * when this function it called, the menu will be rebuilt.
+ *
+ * Tool items must not call this function directly, but rely on
+ * gtk_tool_item_rebuild_menu() instead.
+ *
+ * Since: 2.16
+ **/
+void
+gtk_tool_shell_rebuild_menu (GtkToolShell *shell)
+{
+ GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
+
+ if (iface->rebuild_menu)
+ iface->rebuild_menu (shell);
+}
+
+#define __GTK_TOOL_SHELL_C__
+#include "gtkaliasdef.c"
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2007 Openismus GmbH
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:
+ * Mathias Hasselmann
+ */
+
+#ifndef __GTK_TOOL_SHELL_H__
+#define __GTK_TOOL_SHELL_H__
+
+#include <gtk/gtkenums.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_TOOL_SHELL (gtk_tool_shell_get_type ())
+#define GTK_TOOL_SHELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TOOL_SHELL, GtkToolShell))
+#define GTK_IS_TOOL_SHELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TOOL_SHELL))
+#define GTK_TOOL_SHELL_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_TOOL_SHELL, GtkToolShellIface))
+
+typedef struct _GtkToolShell GtkToolShell; /* dummy typedef */
+typedef struct _GtkToolShellIface GtkToolShellIface;
+
+/**
+ * GtkToolShellIface:
+ * @get_icon_size: mandatory implementation of gtk_tool_shell_get_icon_size().
+ * @get_orientation: mandatory implementation of gtk_tool_shell_get_orientation().
+ * @get_style: mandatory implementation of gtk_tool_shell_get_style().
+ * @get_relief_style: optional implementation of gtk_tool_shell_get_relief_style().
+ * @rebuild_menu: optional implementation of gtk_tool_shell_rebuild_menu().
+ *
+ * Virtual function table for the #GtkToolShell interface.
+ */
+struct _GtkToolShellIface
+{
+ /*< private >*/
+ GTypeInterface g_iface;
+
+ /*< public >*/
+ GtkIconSize (*get_icon_size) (GtkToolShell *shell);
+ GtkOrientation (*get_orientation) (GtkToolShell *shell);
+ GtkToolbarStyle (*get_style) (GtkToolShell *shell);
+ GtkReliefStyle (*get_relief_style) (GtkToolShell *shell);
+ void (*rebuild_menu) (GtkToolShell *shell);
+};
+
+GType gtk_tool_shell_get_type (void) G_GNUC_CONST;
+
+GtkIconSize gtk_tool_shell_get_icon_size (GtkToolShell *shell);
+GtkOrientation gtk_tool_shell_get_orientation (GtkToolShell *shell);
+GtkToolbarStyle gtk_tool_shell_get_style (GtkToolShell *shell);
+GtkReliefStyle gtk_tool_shell_get_relief_style (GtkToolShell *shell);
+void gtk_tool_shell_rebuild_menu (GtkToolShell *shell);
+
+G_END_DECLS
+
+#endif /* __GTK_TOOL_SHELL_H__ */